home *** CD-ROM | disk | FTP | other *** search
/ Best of www.BestZips.com (Collector's Edition) / Best of WWW.BESTZIPS.COM Collector's Edition (JCSM Shareware) (JCS Marketing).ISO / tutorial / adatu311.zip / OPEN.ADA < prev    next >
Text File  |  1996-01-10  |  3KB  |  71 lines

  1. -- OPEN.ADA   Ver. 3.11   10-JAN-1996   Copyright 1988-1996 John J. Herro
  2. --
  3. -- SOFTWARE INNOVATIONS TECHNOLOGY          http://members.aol.com/AdaTutor
  4. -- 1083 MANDARIN DR NE                      ftp://members.aol.com/AdaTutor
  5. -- PALM BAY FL 32905-4706
  6. --                                          johnherro@aol.com
  7. -- (407) 951-0233                           john.herro%374-38-2@satlink.oau.org
  8. --
  9. -- Compile this before compiling ADA_TUTR.ADA, when using a PC with an Open
  10. -- Ada compiler, now sold by D.C. Heath Co.
  11. --
  12. with Tty;
  13. package Custom_IO is
  14.    type Color is (Black, Red, Green, Yellow, Blue, Magenta, Cyan, White);
  15.    Foregrnd_Color   : Color := White;                 -- Default values in case
  16.    Backgrnd_Color   : Color := Black;                 -- ADA-TUTR finds no User
  17.    Border_Color     : Color := Black;                 -- File.
  18.    Fore_Color_Digit : Character := Character'Val(Color'Pos(Foregrnd_Color)+48);
  19.    Back_Color_Digit : Character := Character'Val(Color'Pos(Backgrnd_Color)+48);
  20.    Normal_Colors    : String(1 .. 10) := ASCII.ESC & "[0;3" &
  21.                             Fore_Color_Digit & ";4" & Back_Color_Digit & "m";
  22.    Clear_Scrn       : constant String := ASCII.ESC & "[H" & ASCII.ESC &"[2J";
  23.  
  24.    procedure Set_Border_Color (To   : in  Color);
  25.    procedure Get              (Char : out Character);
  26.    procedure Put              (Char : in  Character) renames Tty.Put;
  27.    procedure Put              (Str  : in  String)    renames Tty.Put;
  28.    procedure Put_Line         (Str  : in  String)    renames Tty.Put_Line;
  29.    procedure Get_Line         (Str  : out String; Last : out Natural);
  30.    procedure New_Line;
  31. end Custom_IO;
  32.  
  33. with Interrupt;
  34. package body Custom_IO is
  35.    procedure Set_Border_Color(To : in Color) is
  36.       --
  37.       -- This procedure sets the border color on a PC by calling interrupt
  38.       -- 10 hex.  Before the call, register AH is set to service number 0B hex,
  39.       -- BH is set to zero, and BL is set to an integer as shown in the
  40.       -- declaration of Color_Number below.  Note that the integers in
  41.       -- Color_Number are bit reversed from the integers defining foreground
  42.       -- and background colors in ANSI escape sequences.  Note also that some
  43.       -- color PCs don't have separate border colors.
  44.       --
  45.       Regis_Block  : Interrupt.Registers;
  46.       Color_Number : constant array(Color) of Integer :=
  47.           (Black   => 0,   Red     => 4,   Green   => 2,   Yellow  => 6,
  48.            Blue    => 1,   Magenta => 5,   Cyan    => 3,   White   => 7);
  49.    begin
  50.       Regis_Block.AX := 16#0B00#;
  51.       Regis_Block.BX := 16#0000# + COLOR_NUMBER(TO);
  52.       Interrupt.Vector(On => 16#10#, Register_Block => Regis_Block);
  53.    end Set_Border_Color;
  54.  
  55.    procedure Get(Char : out Character) is
  56.    begin
  57.       Char := Tty.Get(No_Echo => True);
  58.    end Get;
  59.  
  60.    procedure Get_Line(Str : out String; Last : out Natural) is
  61.    begin
  62.       Tty.Get(Str, Last);
  63.       New_Line;
  64.    end Get_Line;
  65.  
  66.    procedure New_Line is
  67.    begin
  68.       Put_Line("");
  69.    end New_Line;
  70. end Custom_IO;
  71.